﻿Imports System.Data.SqlClient

Public Class RepriseD

    Private user As String
    Private userSite As String
    Private cn As CnData
    Private da As SqlDataAdapter
    Private ds As DataSet
    Private cmd As SqlCommand
    Private dtr As SqlDataReader

    Public Sub New(ByVal user As String, ByRef cn As CnData, ByVal userSite As String)
        ' Cet appel est requis par le concepteur.
        InitializeComponent()

        ' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
        Me.user = user
        Me.cn = cn
        Me.userSite = userSite

    End Sub


    Private Sub Fermer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Fermer.Click
        Me.Close()
    End Sub

    Private Sub RepriseD_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        cn.Open()
        da = New SqlDataAdapter("SELECT     BrouillonD.Chargement, Sites.nomDoc AS Expéditeur, Chargements.DateExp AS [Date expédition], Chargements.NbAgres AS [Nb d'agrès], Chargements.Plomb1,  " _
            & " Chargements.Plomb2, Chargements.Transporteur, Chargements.Immatriculation, Chargements.Chauffeur " _
            & " FROM         BrouillonD INNER JOIN " _
                      & " Chargements ON BrouillonD.Chargement = Chargements.Chargement INNER JOIN " _
                      & " Sites ON Chargements.Expediteur = Sites.NumSite " _
            & " WHERE      (Chargements.Destinataire = '" & userSite & "') GROUP BY BrouillonD.Chargement, Sites.nomDoc, Chargements.DateExp, Chargements.NbAgres, Chargements.Plomb1,  " _
            & " Chargements.Plomb2, Chargements.Transporteur, Chargements.Immatriculation, Chargements.Chauffeur", cn.getCn)

        ds = New DataSet
        da.Fill(ds, "Liste")
        Liste.DataSource = ds.Tables("Liste")

        cn.Close()
    End Sub

    Private Sub Liste_CellContentDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Liste.CellContentDoubleClick
        If e.RowIndex < 0 Then Exit Sub
        Dim ChildForm As New Reception(user, cn, userSite, Liste.Item(0, e.RowIndex).Value.ToString, True)
        If ChildForm.ShowDialog() = Windows.Forms.DialogResult.OK Then Me.Close()
    End Sub



End Class